<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
        function * gen(arg) {
            console.log('🚀 ~ This is a result of console.log ~ ✨: ', arg);
            const res = yield '两只老虎'
            console.log('🚀 ~ This is a result of console.log ~ ✨:--- ', res);
            yield '一只没有耳朵，一只没有尾巴'
            console.log('🚀 ~ This is a result of console.log ~ ✨:--- ');
            yield '真奇怪'
            console.log('🚀 ~ This is a result of console.log ~ ✨: ', arg)
        }

        // gen('123')
        const itera = gen('123')
        console.log('🚀 ~ This is a result of console.log ~ ✨: ', itera.next());
        console.log('🚀 ~ This is a result of console.log ~ ✨: ', itera.next('hon'));
        // next('参数') next 中如果传入参数， 会是上一个 yield 的返回值
        const a = Promise.resolve('1')
        const b = Promise.reject('2')
        const c = Promise.resolve('3')
        const d = Promise.resolve('4')

        const result = Promise.allSettled([a, b, c, d])
        console.log('🚀 ~ This is a result of console.log ~ ✨: ', result);
        console.log('🚀 ~ This is a result of console.log ~ ✨: ', Promise.all([a, b, c, d]));
    </script>
</body>
</html>
